<?php 
	$host = "127.0.0.1";
	$userName = "root";
	$pwd = "root";
	$dbName = "text";
	$dbms='mysql';
	$dsn="$dbms:host=$host;dbname=$dbName";
	try {
		$db = new PDO($dsn,'root','root');
		//echo "连接成功。";
	} catch (Exception $exc) {
		//echo $exc->getMassage();
	}

	$sql = "SELECT * FROM `class` WHERE id = ".$_POST['operate'];
	$result = $db->query($sql);
	$result->setFetchMode(PDO::FETCH_ASSOC);
	while($row=$result->fetch()){
		$str = $row['name'];
	}

	$db->query('set names utf8');
	$sql = "INSERT INTO `test`(`name`,`tea`, `class`, `time`, `place`, `checkId`, `classID`) VALUES ('".$str."','".$_POST['tea']."','".$_POST['class']."','".$_POST['time']."','".$_POST['place']."',0,".$_POST['operate'].")";
	$db->query($sql);
	$db->query("UPDATE `class` SET `checkID`=1 WHERE id = ".$_POST['operate']);
	exit();
?>